<%@page contentType="text/html; charset=utf-8"%>
<%@ include file="../inc/TagLibs.jsp"%>
<c:set var="pageTitle" value="附件" />
<%@ include file="../inc/Title.jsp"%>
<head>
<link rel="stylesheet" type="text/css" href="/css/base.css" />
<script src="/js/popup_ext.js"></script>
<script language="javascript">
	function doSave(){
		if(document.getElementById("acc_type1")!=null){
			var wcId=document.getElementById("extId").value;
			if(document.getElementById("acc_type1").checked && (wcId=="" || wcId=="0")){
				ShowAlert('提示框','请选择工作中心！',200,100);
				return;
			}
		}
		if(document.getElementById("hid_file_name")!=null){
			var fn=document.getElementById("accessory_file").value.trim();
			if(fn!=null && fn!=""){
				fn=fn.toLowerCase();
				if(fn.endWith(".exe") || fn.endWith(".bat") || fn.endWith(".com") || fn.endWith(".jsp") || fn.endWith(".htm") || fn.endWith(".html")){
					ShowAlert('提示框','不能上传.exe、.bat、.com、.jsp、.htm或.html格式的文件！',200,100);
					return;
				}
			}
			document.getElementById("tblUpload").style.display="none";
			document.getElementById("postframe").height="100%";
			document.getElementById("postframe").style.display="";
			document.getElementById("hid_file_name").value=document.getElementById("accessory_file").value;
		}
		frm.submit();
	}
	function doCancel(){
		parent.ClosePop();
	}
	function showMe(){
		showFormErrorMsg();
		
		if(checkNavigator()[0]!="msie"){
			if(document.getElementById("accessory_file")!=null){
				document.getElementById("accessory_file").className="";
			}
		}
	}
	function changeAccType(){
		if(document.getElementById("acc_type1").checked){
			document.getElementById("accType").value="DESIGN";
		}else if(document.getElementById("acc_type2").checked){
			document.getElementById("accType").value="COOPER";
			document.getElementById("extId").options[0].selected=true;
		}else{
			document.getElementById("accType").value="CONTRACT";
			document.getElementById("extId").options[0].selected=true;
		}
	}
	function browseFolder(){
		try{
			var shell = new ActiveXObject("Shell.Application");
			var folder = shell.BrowseForFolder(0, "请选择目录", 64, 17);//起始目录为：我的电脑
			//var folder = shell.BrowseForFolder(0,"请选择目录",0); //起始目录为：桌面
			if(folder!=null){
				folder = folder.items(); // 返回 FolderItems 对象
            	folder = folder.item(); // 返回 Folderitem 对象
            	folder = folder.Path;   // 返回路径
            	if (folder.charAt(folder.length - 1) != "\\") {
                	folder = folder + "\\";
            	}
            	document.getElementById("customPath").value = folder;
			}
		}catch(e){
			ShowAlert('提示框',e.message,200,100);
		}
	}
</script>
</head>
<body oncontextmenu="return false" scroll="no" onLoad="showMe();" class="sheet modal-dialog" style="padding-top:10px;">

<c:if test="${id==null || id==''}">
	<c:set var="pageTopTitle" value="新增附件" />
</c:if>
<c:if test="${id!=null && id!=''}">
	<c:set var="pageTopTitle" value="编辑附件" />
</c:if>

<div class="sheet-main" style="width:530px;" id="tblUpload">
  <form name="frm" method="post" enctype="multipart/form-data">
  <div class="sheet-list" style="width:100%">
    <div class="modal-main search-business">
 		<div style="width:100%;">
			<%@ include file="../inc/PageTop.jsp"%>
			
			<c:if test="${id==null || id==''}">
				<div class="blank12"></div> 
				<table border="0" cellspacing="1" cellpadding="1" align="center" class="table-0" >
					<tr>			   	
				      	<th style="width:25%">上传到服务器：</th>
				      	<td style="width:75%">
							<input type="file" onKeyUp="goNextInput('mark');" id="accessory_file" name="accessory_file" style="width:220px" class="TextBox">
							<input type="hidden" id="hid_file_name" name="hid_file_name" >					
							<spring:bind path="command.fileName">
					          <script language="javascript">
					          	setFormErrorMsg('<c:out value="${status.errorMessage}" />',3,'accessory_file');
					          </script>
							</spring:bind>
				     	</td>
					</tr>
					<tr>
				      	<th>文件说明：</th>
				      	<spring:bind path="command.mark">
				      	<td>
				      		<input type="text" maxlength="50" onKeyUp="goNextInput('');" id="${status.expression}" name="${status.expression}" value="${status.value}" style="width:220px" class="TextBox">
					          <script language="javascript">
					          	setFormErrorMsg('<c:out value="${status.errorMessage}" />',1,'mark');
					          </script>
				     	</td>
				     	</spring:bind>
					</tr>
				</table>
			</c:if>
			
			<c:if test="${id!=null && id!=''}">
				<table border="0" cellspacing="1" cellpadding="1" align="center" class="table-0" >
					 <tr>			   	
				      	<th style="width:25%">文件：</th>
				      	<td style="width:75%">${command.sourceName}</td>
					</tr>
					<tr>			   	
				      	<th>资料路径：</th>
						<spring:bind path="command.customPath">
				      	<td>
				      		<input type="text" maxlength="100" onKeyUp="goNextInput('mark');" id="${status.expression}" name="${status.expression}" value="${status.value}" style="width:180px" class="TextBox">
				      		<input type="button" value="..." onClick="browseFolder();">
					          <script language="javascript">
					          	setFormErrorMsg('<c:out value="${status.errorMessage}" />',2,'customPath');
					          </script>
				     	  </td>
				     	  </spring:bind>
					</tr>
					<tr>
				      	<th>文件说明：</th>
				      	<spring:bind path="command.mark">
				      	<td>
				      		<input type="text" maxlength="50" onKeyUp="goNextInput('');" id="${status.expression}" name="${status.expression}" value="${status.value}" style="width:200px" class="TextBox">
					          <script language="javascript">
					          	setFormErrorMsg('<c:out value="${status.errorMessage}" />',3,'mark');
					          </script>
				     	  </td>
				     	  </spring:bind>
					</tr>
					<c:if test="${type=='SHOW_EXT'}">
					<tr>
				      	<th>工作中心：</th>
				      	<spring:bind path="command.extId">
				      	<td>
				      		<select name='${status.expression}' id='${status.expression}'>
				      			<option value="0">==请选择==</option>
								<c:forEach var="wcItem" items="${wcList}">
									<option value="${wcItem.id}" <c:if test="${status.value==wcItem.id}">selected="true"</c:if>>${wcItem.wcName}</option>
								</c:forEach>
				  			</select>
				      	</td>
				     	</spring:bind>
					</tr>
					<tr>
				      	<th>文件类型：</th>
				      	<td>
				      		<input type="radio" name="acc_type" id="acc_type1" onClick="changeAccType();" <c:if test="${command.accType=='DESIGN'}">checked</c:if>>自制
							<input type="radio" name="acc_type" id="acc_type2" onClick="changeAccType();" <c:if test="${command.accType=='COOPER'}">checked</c:if>>外协
							<input type="radio" name="acc_type" id="acc_type3" onClick="changeAccType();" <c:if test="${command.accType=='CONTRACT'}">checked</c:if>>合同
							<spring:bind path="command.accType">
								<input type="hidden" name="${status.expression}" id="${status.expression}" value="${status.value}">
							</spring:bind>
				      	</td>
					</tr>
					</c:if>
				</table>
			</c:if>
			</div>
		</div>
	</div>
	<div class="modal-buttom">
		<input type="button" class="buttom-a" value=" 保 存 " onClick="doSave();" >
		<input type="button" class="buttom-a" value=" 取 消 " onClick="doCancel();" >		
	</div>
	</form>
</div>
<iframe name="postframe" height="0" width="100%" frameborder="0" scrolling="no" style="display:none" id="postframe" src="/uploading.jsp"></iframe>
</body>
</html>